﻿Public Class frm_opensfdl_encrypted

    Private _password As String
    Private _test_decrypt_string As String

    Public ReadOnly Property GetPassword As String
        Get
            Return _password
        End Get
    End Property

    Public WriteOnly Property SetTestDecryptString As String
        Set(value As String)
            _test_decrypt_string = value
        End Set
    End Property


    Private Sub cmd_ok_Click(sender As Object, e As EventArgs) Handles cmd_ok.Click

        Dim _crypto As New Crypto.AES
        Dim _tmp As String

        _password = txt_sfdl_pw.Text

        Try

            _tmp = _crypto.DecryptString(_test_decrypt_string, _password)

            Me.DialogResult = Windows.Forms.DialogResult.OK
            Me.Close()

        Catch ex As Crypto.FalsePasswordException
            MessageBox.Show("Falsches Kennwort!", "Falsches Kennwort", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            txt_sfdl_pw.Clear()
        End Try

    End Sub

    Private Sub txt_sfdl_pw_KeyDown(sender As Object, e As KeyEventArgs) Handles txt_sfdl_pw.KeyDown
        If e.KeyCode = Keys.Return Or e.KeyCode = Keys.Enter Then
            cmd_ok.PerformClick()
        End If
    End Sub

    Private Sub frm_opensfdl_encrypted_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub cmd_cancel_Click(sender As Object, e As EventArgs) Handles cmd_cancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub
End Class